package com.example.controller;

import com.example.domain.CultureProject;
import com.example.domain.vo.Result;
import com.example.service.CultureDeclareService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/front/culture/declare")
@Slf4j
public class CultureDeclareController {
    @Autowired
    private CultureDeclareService cultureDeclareService;

    @PostMapping("/add")
    public Result addCulture(@RequestBody CultureProject cultureProject) {
        cultureDeclareService.addCulture(cultureProject);
        return Result.success();
    }

    @GetMapping
    public Result queryCulture(CultureProject cultureProject) {
        List<CultureProject> project = cultureDeclareService.queryCulture(cultureProject);
        return Result.success(project);
    }

    @GetMapping("/category")
    public Result queryCultureCategory() {
        List<Map<String, Long>> category = cultureDeclareService.queryCultureCategory();
        return Result.success(category);
    }
}
